<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>送货单</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.table-bordered {
			border-collapse: collapse;
			border-radius: 0px;
			margin-bottom: 10px;
		}
		.table td {
			vertical-align: middle;
			text-align: center;
			padding: 0px;
			margin: 0px;
			height: 30px;
		}
		.top_table td {
			vertical-align: middle;
			text-align: left;
			padding: 0px;
			margin: 0px;
			height: 30px;
			border: 0px;
		}
		.bottom_line{
			border-bottom: 2px solid;
		}
		.center{
			text-align: center;
		}
		.footer {
			position:fixed; bottom:0; background:#ABABAB; width:100%; height:35px; line-height:32px; z-index:9999; opacity:1;
			filter:alpha(opacity=60); _bottom:auto; _width:100%; _position:absolute;text-align: right;
			_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-
			(parseInt(this.currentStyle.marginTop, 10)||0)-(parseInt(this.currentStyle.marginBottom, 10)||0)));
	    }
	</style>
	<script type="text/javascript">
		var dcost = 0;
		var fee = ${fee};//配送费
		var lowFee = ${lowFee};//起送费
		$(document).ready(function() {
			var nodeLen = $(".jbox-button-panel", top.document).length;
			$(".jbox-button-panel", top.document).eq(nodeLen-1).remove();
			if(${toCreate}){
				parent.mainFrame.location.reload();
				document.location="${ctx}/ivm/order/delivery/deliveryDetail?orderId=${order.id}";
			}
			$("#inputForm").validate({
				submitHandler: function(form){
					var amounts = $(".total-amount").html();
					if(amounts==undefined){
						amounts = 0;
					}
					$("input[id='deliveryInfo.amount']").val(amounts);
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					error.insertAfter(element);
				}
			});
			
			var totalAmount = 0;
			$("input[name='numbers']").each(function(){
				var number = $(this).val();
				var price = $(this).parent().prev().html();
				totalAmount = accAdd(accMul(price,number),totalAmount);
			});
			if(parseFloat($(".total-amount").html())!=totalAmount){
				dcost = fee;
			}
		});
		
		//设置送货员
		function setDeliveryPerson(val,orderId,deliveryId){
			var memberId = $("#memberId").val();
			if(memberId == ""){
				showJBoxMess("请选择送货员.","error");
				return;
			}
			//异步提交送货员设定
			loading("正在提交，请稍等...");
			$.ajax({
				type: 'get',
				url: '${ctx}/ivm/order/delivery/setDeliveryPerson',
				data: 'memberId='+memberId+"&orderId="+orderId+"&status="+val+"&deliveryId="+deliveryId,
				dataType: 'json',
				success: function(data){
					if(data.status==200){
						showJBoxMess(data.message,"success");
						parent.mainFrame.location.reload();
						document.location="${ctx}/ivm/order/delivery/deliveryInfo?id="+orderId;
					}else{
						showJBoxMess(data.message,"error");
					}
				},
				failure: function(){
					showJBoxMess("操作失败","error");
				}
			});
		}
		
		//操作流程
		function startWorkFlow(workFlowId,deliveryIndentId,status){
			var orderId=$("#orderId").val();
			if(status == "2"){
				if($("#signTime").val()==""){
					showJBoxMess("请输入签收时间.","error");
					$("#signTime").focus();
					return;
				}
			}
			var deliveryInfoId = $("#id").val();
			var signTime = $("#signTime").val();
			var receiptMarks = $("#receiptMarks").val();
			var remarks = "";
			if(status == "0"){
				remarks = "开启派送流程.";
			}else if(status == "1"){
				remarks = "开始派送订单.";
			}else{
				remarks = "完成订单派送.";
			}
			var orderId=$("#orderId").val();
			loading("正在提交，请稍等...");
			//异步提交流程启动
			$.ajax({
				type: 'post',
				url: '${ctx}/ivm/order/delivery/startWorkFlow',
				data: 'orderId='+orderId+"&workFlowId="+workFlowId+"&indentId="+deliveryIndentId+"&status="+status+"&remarks="+remarks+"&deliveryInfoId="+deliveryInfoId+"&receiptMarks="+receiptMarks+"&signTime="+signTime,
				dataType: 'json',
				success: function(data){
					if(data.status==200){
						showJBoxMess(data.message,"success");
						parent.mainFrame.location.reload();
						document.location="${ctx}/ivm/order/delivery/deliveryInfo?id="+orderId;
					}else{
						showJBoxMess(data.message,"error");
					}
				},
				failure: function(){
					showJBoxMess("操作失败","error");
				}
			});
		}
		
		//修改商品数量
		function changeNumber(obj){
			updateNum(obj, 0);
			var price = $(obj).parent().next().find("input[name='prices']").val();
			var number = $(obj).val();
			$(obj).parent().next().next().html(accMul(price,number));
			$(obj).parent().parent().find("input[name='amounts']").val(accMul(price,number));
			calAmount();
		}
		
		//修改单价
		function changePrice(obj){
			var ff = /^\d+(\.\d+)?$/;
			var val = $(obj).val();
			if(!ff.test(val)){
				alert("请输入整数或小数.");
				$(obj).val("");
			}
			var price = $(obj).val();
			var number = $(obj).parent().prev().find("input[name='numbers']").val();
			$(obj).parent().next().html(accMul(price,number));
			$(obj).parent().parent().find("input[name='amounts']").val(accMul(price,number));
			calAmount();
		}
		//修改单价、数量或删除商品时：重新计算总金额
		function calAmount(){
			var totalAmount = 0;
			$("input[name='numbers']").each(function(){
				number = $(this).val();
				price = $(this).parent().next().find("input[name='prices']").val();
				totalAmount = accAdd(accMul(price,number),totalAmount);
			});
			if(totalAmount<lowFee){
				$(".total-amount").html(totalAmount+dcost);
				$(".total-amount2").html(totalAmount+dcost);
			}else{
				$(".total-amount").html(totalAmount);
				$(".total-amount2").html(totalAmount);
			}
			if(${order.payType!=1}){
				var oldAmount = $("input[id='deliveryInfo.amount']").val();
				$(".total-refund").html(accSub(oldAmount,totalAmount));
				$(".total-refund2").html(accSub(oldAmount,totalAmount));
				$("input[id='deliveryInfo.refund']").val(accSub(oldAmount,totalAmount));
			}
		}
		
		//重置送货单
		function resetDelivery(type){
			var msgInfo = "是否确认还原送货单？";
			if(type==2){//确认还原
				msgInfo = "是否确认取消还原？";
			}
			top.$.jBox.defaults.top="28%";
			top.$.jBox.confirm(msgInfo,'系统提示',function(v,h,f){
				if(v=='ok'){
					var orderId=$("#orderId").val();
					loading("正在提交，请稍等...");
					$.ajax({
						type: 'post',
						url: '${ctx}/ivm/order/delivery/resetDelivery',
						data: 'orderId='+orderId+'&type='+type,
						dataType: 'json',
						success: function(data){
							if(data.status==100){//只点击
								parent.mainFrame.location.reload();
								document.location="${ctx}/ivm/order/delivery/deliveryInfo?id="+orderId+"&type="+type;
							}else if(data.status==200){//确认还原
								parent.mainFrame.location.reload();
								document.location="${ctx}/ivm/order/delivery/deliveryInfo?id="+orderId+"&type="+type;
								showJBoxMess(data.message,"success");
							}else if(data.status==300){//取消还原
								parent.mainFrame.location.reload();
								document.location="${ctx}/ivm/order/delivery/deliveryInfo?id="+orderId+"&type="+type;
								showJBoxMess(data.message,"success");
							}else{
								showJBoxMess(data.message,"error");
							}
						},
						failure: function(){
							showJBoxMess("操作失败","error");
						}
					});
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		}
		//预览送货单
        function previewDelivery(id){
        	top.$.jBox.defaults.top="8%";
        	top.$.jBox.open("iframe:${ctx}/ivm/order/delivery/previewDelivery?id="+id, "送货单预览",$(top.document).width()-400,$(top.document).height()-100,{
				buttons:{"确定":true}, loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
				}
			});
        }
        
        //检测商品编号
        function checkProductCode(){
        	if($("#code").val()==""){
				showJBoxMess("请输入商品编号或名称.","error");
				return;
			}
			var obj = $("#code");
			if($(obj).val()!=""){
				//异步保存活动
				$.ajax({
					type: 'post',
					url: '${ctx}/ivm/inventory/checkProductCode',
					data: 'merchantId=${order.merchant.id}&code='+$(obj).val(),
					dataType: 'json',
					success: function(data){
						if(data.status==200){
							var product = data.result;
							var isExists = false;
				        	$("input[id='productCode']").each(function(){
				        		if($(this).val()==product.code){
				        			showJBoxMess("商品"+$(obj).val()+"已存在，请重新输入！","error");
				        			isExists=true;
				        			return false;
				        		}
				        	});
				        	if(isExists) return;
				        	createDeliveryDetail();
						}else{
							showJBoxMess(data.message,"error");
						}
					},
					failure: function(){
						showJBoxMess("操作失败","error");
					}				
				});
			}
		}
		
		function createDeliveryDetail(){
			//异步手动生成商品采购清单
			$.ajax({
				type: 'get',
				url: '${ctx}/ivm/order/delivery/productDetail',
				data: 'merchantId=${order.merchant.id}&code='+$("#code").val(),
				dataType: 'json',
				success: function(data){
					if(data.status==200){
						//获取商品最大的排序号
						var maxNum = $("input[name='detailIds']").length;
						$("input[name='sorts']").each(function(obj){
							if($(this).val()-maxNum>0){
								maxNum = $(this).val();
							}
						});
						maxNum = parseInt(maxNum)+1;
						var product = data.result;
						var html = '<tr>';
						html += '<td>';
						html += '<input type="hidden" name="sorts" value="'+maxNum+'"/>';
						html += '<input type="hidden" name="detailIds" value="null"/>';
						html += '<input type="hidden" name="products" value="'+product.id+'"/>';
						html += '<input type="hidden" id="productCode" value="'+product.code+'"/>';
						html += '<input type="hidden" name="amounts" value="0"/>';
						html += product.name;
						html += '&nbsp;<a href="javascript:;" onclick="delProduct(this)"><img src="${ctxStatic }/images/close.png" height="16" width="16" title="删除该商品"/></a>';
						html += '</td>';
						html += '<td>'+product.assisTitle+'</td>';
						html += '<td>';
						html += '<input name="numbers" value="0" onchange="changeNumber(this)" htmlEscape="false" maxlength="20" min="1" class="required" style="text-align: center; width: 100%; height: 100%; padding: 0px; margin:0px;"/>';
						html += '</td>';
						html += '<td>';
						html += '<input name="prices" value="'+product.price+'" onchange="changePrice(this)" htmlEscape="false" maxlength="20" class="required" style="text-align: center; width: 100%; height: 100%; padding: 0px; margin:0px;"/>';
						html += '</td>';
						html += '<td>'+0.0+'</td>';
						html += '</tr>';
						if($("input[name='detailIds']").length==0){
							$(".details").find("tr").remove();
						}
						$(".details").append(html);
						$("#code").val("");
					}else{
						showJBoxMess(data.message,"error");
					}
				},
				failure: function(){
					showJBoxMess("操作失败","error");
				}				
			});
		}
		//删除商品
		function delProduct(obj){
			top.$.jBox.defaults.top="28%";
			top.$.jBox.confirm("确认要删除该商品吗",'系统提示',function(v,h,f){
				if(v=='ok'){
					$(obj).parent().parent().remove();
					calAmount();
					if($(".details").find("tr").length==0){
						var html = "<tr><td>&nbsp;</td><td></td><td></td><td></td><td></td><tr>";
						$(".details").append(html);
					}
				}
			},{buttonsFocus:1});
		}
		//保存
		function saveForm(){
			if($("input[name='detailIds']").length==0){
				showJBoxMess("对不起，商品列表不能为空，请添加商品！","error");
				return;
			}else{
				top.$.jBox.defaults.top="28%";
				top.$.jBox.confirm("确认保存吗？",'系统提示',function(v,h,f){
					if(v=='ok'){
						$('#inputForm').submit();
					}
				},{buttonsFocus:1});
			}
		}
		//导出word
		function exportWord(id){
			$.ajax({
				type: 'post',
				url: '${ctx}/ivm/order/exportWord',
				data: 'orderIds='+id,
				dataType: 'json',
				success: function(data){
					if(data.status==200){
						document.location.href= '${ctx}/download?filePath='+URLencode(data.message);
					}else{
						showJBoxMess(data.message,"error");
					}
				},
				failure: function(){
					showJBoxMess("操作失败","error");
				}
			});
		}
	</script>
</head>
<body>
<div style="margin:10px 20px 50px 20px;">
	<form:form id="inputForm" modelAttribute="deliveryInfo" action="${ctx}/ivm/order/delivery/saveDelivery" method="post">
		<form:hidden path="id"/>
		<form:hidden path="order.id"/>
		<form:hidden path="order.merchant.id"/>
		<tags:message content="${message}"/>
		<input type="hidden" id="orderId" value="${order.id }"/>
		<form:hidden id="deliveryInfo.amount" path="amount" />
		<form:hidden id="deliveryInfo.refund" path="refund" />
		<form:hidden id="deliveryNo" path="deliveryNo" />
		<!-- 收货人信息 -->
		<table class="table top_table" width="100%">
			<tr class="bottom_line">
				<td colspan="4" style="text-align: right;">
					<span style="font-size: 22px;"><strong>派送单</strong></span>
					<span>客户联</span>
					<span style="padding-left: 30%;">${order.deliveryNo }</span>
				</td>
			</tr>
			<tr>
				<td width="10%">收货人：</td>
				<td width="40%">${deliveryInfo.name }
					<!-- <input name="name" value="${deliveryInfo.name }" htmlEscape="false" maxlength="20" class="required" style="padding: 0px; margin:0px;"/> -->
				</td>
				<td width="10%">收货地址：</td>
				<td width="40%">${deliveryInfo.address }
					<!-- <input name="address" value="${deliveryInfo.address }" htmlEscape="false" maxlength="100" class="required" style="width:100%; padding: 0px; margin:0px;"/> -->
				</td>
			</tr>
			<tr class="bottom_line">
				<td>联系电话：</td>
				<td>${deliveryInfo.phone }
					<!-- <input name="phone" value="${deliveryInfo.phone }" htmlEscape="false" maxlength="20" class="required" style="padding: 0px; margin:0px;"/> -->
				</td>
				<td>收货时间：</td>
				<td>${deliveryInfo.timeText }
					<!-- <input name="timeText" value="${deliveryInfo.timeText }" htmlEscape="false" maxlength="100" class="required" style="width:100%; padding: 0px; margin:0px;"/> -->
				</td>
			</tr>
		</table>
		<table class="table-condensed center" border="1" width="100%">
			<tr>
				<th width="20%">支付状态</th>
				<th width="25%">
					<c:if test="${order.payType== '1'}">应收金额</c:if>
					<c:if test="${order.payType!= '1'}">应退金额</c:if>
				</th>
				<th width="55%">特殊状态标识</th>
			</tr>
			<tr>
				<td>
					<c:if test="${order.payType== '1'}">到付</c:if>
					<c:if test="${order.payType!= '1'}">网付</c:if>
				</td>
				<td>
					<c:if test="${order.payType== '1'}"><label class="total-amount">${deliveryInfo.amount }</label>元</c:if>
					<c:if test="${order.payType!= '1'}"><label class="total-refund">${deliveryInfo.refund }</label>元</c:if>
				</td>
				<td>
					<!-- <input name="specialMark" value="${deliveryInfo.specialMark }" htmlEscape="false" maxlength="100" style="text-align: center; width: 100%; padding: 0px; margin:0px;"/> -->
				</td>
			</tr>
		</table>
		<p style="padding-top: 20px;" class="bottom_line"></p>
		<!-- 送货单信息 -->
		<table class="table-condensed center" border="1" width="100%" style="margin-top: 20px;">
			<thead>
				<tr>
					<th>商品名细</th>
					<th style="width:17%">规格</th>
					<th style="width:17%">数量</th>
					<th style="width:17%">单价</th>
					<th style="width:17%">小计</th>
				</tr>
			</thead>
			<tbody class="details">
				<c:forEach items="${order.deliveryList}" var="deliveryDetail">
				<tr>
					<td>
						<input type="hidden" name="sorts" value="${deliveryDetail.sort }"/>
						<input type="hidden" name="detailIds" value="${deliveryDetail.id }"/>
						<input type="hidden" name="products" value="${deliveryDetail.product.id }"/>
						<input type="hidden" id="productCode" value="${deliveryDetail.product.code }"/>
						<input type="hidden" name="amounts" value="${deliveryDetail.amount }"/>
						${deliveryDetail.product.name }&nbsp;
						<!-- a href="javascript:;" onclick="delProduct(this)"><img src="${ctxStatic }/images/close.png" height="16" width="16" title="删除该商品"/></a -->
					</td>
					<td>${deliveryDetail.product.assisTitle }</td>
					<td>
						<!--<input name="numbers" value="${deliveryDetail.number }" onchange="changeNumber(this)" htmlEscape="false" maxlength="20" min="1" class="required" style="text-align: center; width: 100%; height: 100%; padding: 0px; margin:0px;"/>-->
						${deliveryDetail.number}
					</td>
					<td>
						<!-- <input name="prices" value="${deliveryDetail.price }" onchange="changePrice(this)" htmlEscape="false" maxlength="20" class="required" style="text-align: center; width: 100%; height: 100%; padding: 0px; margin:0px;"/>-->
						${deliveryDetail.price}
					</td>
					<td>${deliveryDetail.amount }</td>
				</tr>
				</c:forEach>
			</tbody>
			<tbody>
				<tr>
					<td>温馨提示</td>
					<td colspan="4">${deliveryInfo.prompt }
						<!--<form:textarea path="prompt" htmlEscape="false" maxlength="200" class="input-xxlarge" style="width: 100%; height: 70px; padding: 0px; margin:0px;"/>-->
					</td>
				</tr>
			</tbody>
		</table>
		<!-- 派送单回单联 -->
		<c:if test="${order.workflowNode==5 || order.workflowNode==6 || order.workflowNode==8 || order.workflowNode==9}">
		<table class="table-condensed center" width="100%" style="margin-top: 20px;">
			<tr>
				<td colspan="4" style="text-align: right;">
					<span style="font-size: 22px;"><strong>派送单</strong></span>
					<span>回单联</span>
					<span style="padding-left: 30%;">${order.deliveryNo }</span>
				</td>
			</tr>
		</table>
		<table class="table-condensed" width="100%" border="1">
			<tr>
				<td style="width:17%">客户姓名</td>
				<td>${deliveryInfo.name}</td>
				<td style="width:17%">要求送达时间</td>
				<td style="width:17%">${deliveryInfo.timeText}</td>
				<td style="width:11%">
					<c:if test="${order.payType== '1'}">应收金额</c:if>
					<c:if test="${order.payType!= '1'}">应退金额</c:if>
				</td>
				<td style="width:11%">
					<c:if test="${order.payType== '1'}"><label class="total-amount2">${deliveryInfo.amount }</label></c:if>
					<c:if test="${order.payType!= '1'}"><label class="total-refund2">${deliveryInfo.refund }</label></c:if>
				</td>
			</tr>
			<tr>
				<td rowspan="2">收货地址</td>
				<td rowspan="2">${deliveryInfo.address}</td>
				<td>实际送达时间</td>
				<td>
					<input id="signTime" name="signTime" style="width: 120px;" 
					value="<fmt:formatDate value="${order.deliveryInfo.signTime}" pattern="yyyy-MM-dd HH:mm"/>" 
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:true});"/>
				</td>
				<td>
					<c:if test="${order.payType== '1'}">实收金额</c:if>
					<c:if test="${order.payType!= '1'}">实退金额</c:if>
				</td>
				<td>
					<c:if test="${order.payType== '1'}"><input name="realAmount" value="${deliveryInfo.realAmount }" htmlEscape="false" maxlength="20" style="width: 55px;padding: 0px; margin:0px;"/>元</c:if>
					<c:if test="${order.payType!= '1'}"><input name="realRefund" value="${deliveryInfo.realRefund }" htmlEscape="false" maxlength="20" style="width: 55px;padding: 0px; margin:0px;"/>元</c:if>
				</td>
			</tr>
			<tr>
				<td>客户签字：</td>
				<td colspan="3"></td>
			</tr>
			<tr height="52px">
				<td>订单备注</td>
				<td colspan="5">
					<form:textarea path="receiptMarks" htmlEscape="false" rows="2" maxlength="200" class="input-xxlarge" style="width: 100%; height: 100%; padding: 0px; margin:0px;"/>
				</td>
			</tr>
		</table>
		</c:if>
	</form:form>
	<c:if test="${(order.payType != '1' && order.payStatus == '1') || order.payType == '1'}">
	<!-- 派送员信息 -->
	<ul class="wl-tab-nav">
		<li><span>${workflow==null?"送货员设置":workflow.delFlag==1?"送货员设置":"送货员信息"}</span></li>
	</ul>
	<div class="delivery_info">
	<c:if test="${workflow==null || workflow.delFlag==1}">
		<label>送货员:</label>
		<form:select id="memberId" path="order.deliveryIndent.deliveryMember.id" class="required input-small">
			<form:option value="" label="请选择"/>
			<form:options items="${fns:getDeliveryMemberList(1)}" itemLabel="name" itemValue="id" htmlEscape="false"/>
		</form:select>
	</c:if>
	<c:if test="${workflow!=null && workflow.status > 0 && workflow.delFlag==0}">
		<label>姓名:${order.deliveryIndent.deliveryMember.name }</label>　　
		<label>电话:${order.deliveryIndent.deliveryMember.phone }</label>
	</c:if>
	</div>
	</c:if>
	<ul class="wl-tab-nav">
		<li><span>送货流程图</span></li>
	</ul>
	<div style="width: 100%;height: auto;text-align: center;">
		<!-- 流程图片 -->
		<table class="table table-striped table-bordered table-condensed">
			<tr>
				<td>
					<!-- 待付款 -->
					<c:if test="${order.workflowNode==1}">
					<img src="${ctxFront }/images/orderWorkFlow/1.png" height="65px" width="760px"/>
					</c:if>
					<!-- 已支付，处理中 -->
					<c:if test="${order.workflowNode==2}">
					<img src="${ctxFront }/images/orderWorkFlow/2.png" height="65px" width="760px"/>
					</c:if>
					<!-- 货到付款，处理中 -->
					<c:if test="${order.workflowNode==3}">
					<img src="${ctxFront }/images/orderWorkFlow/3.png" height="65px" width="760px"/>
					</c:if>
					<!-- 已支付，处理中，已指定送货员 -->
					<c:if test="${order.workflowNode==4}">
					<img src="${ctxFront }/images/orderWorkFlow/4.png" height="65px" width="760px"/>
					</c:if>
					<!-- 已支付，处理中，已指定送货员，配送中 -->
					<c:if test="${order.workflowNode==5}">
					<img src="${ctxFront }/images/orderWorkFlow/5.png" height="65px" width="760px"/>
					</c:if>
					<!-- 已支付，处理中，已指定送货员，配送中，已完成 -->
					<c:if test="${order.workflowNode==6}">
					<img src="${ctxFront }/images/orderWorkFlow/6.png" height="65px" width="760px"/>
					</c:if>
					<!-- 货到付款，处理中，已指定送货员 -->
					<c:if test="${order.workflowNode==7}">
					<img src="${ctxFront }/images/orderWorkFlow/7.png" height="65px" width="760px"/>
					</c:if>
					<!-- 货到付款，处理中，已指定送货员，配送中 -->
					<c:if test="${order.workflowNode==8}">
					<img src="${ctxFront }/images/orderWorkFlow/8.png" height="65px" width="760px"/>
					</c:if>
					<!-- 货到付款，处理中，已指定送货员，配送中，已完成 -->
					<c:if test="${order.workflowNode==9}">
					<img src="${ctxFront }/images/orderWorkFlow/9.png" height="65px" width="760px"/>
					</c:if>
					<!-- 部分完成 
					<img src="${ctxFront }/images/orderWorkFlow/${order.orderType==0&&workflow.status==0?'1':order.orderType==0&&workflow.status==1?'2':order.orderType==1?'3':'4' }.png" height="65px" width="760px"/>
					-->
				</td>
			</tr>
		</table>
	</div>
	<!-- 派送记录 -->
	<c:if test="${workflow != null && workflow.status != 0}">
	<ul class="wl-tab-nav">
		<li><span>送货流程动态</span></li>
	</ul>
	<div style="width: 100%;">
		<table class="table table-striped table-bordered table-condensed" width="100%">
			<thead>
				<tr>
					<th style="text-align:center;width:30%">时间</th>
					<th style="text-align:center;width:50%">内容</th>
					<th style="text-align:center;">操作人</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${workflow.detailList}" var="workflowDetail">
				<tr>
					<td><fmt:formatDate value="${workflowDetail.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td>${workflowDetail.remarks }</td>
					<td>${workflowDetail.createBy.name }</td>
				</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
	</c:if>
</div>
<!--endprint-->
<c:if test="${(order.payType != '1' && order.payStatus == '1') || order.payType == '1'}">
<div class="footer">
	<c:if test="${(order.payType != '1' && order.payStatus == '1') || order.payType == '1'}">
		<!--<c:if test="${order.orderType<2}">
		<input type="text" id="code" name="code" htmlEscape="false" maxlength="200" class="input-small" style="margin-bottom: 0px; width: 180px;" placeholder="请输入商品编号或商品名称"/>
		<input class="btn btn-primary" type="button" onclick="checkProductCode()" value="添加商品"/>
		</c:if>-->
		<c:if test="${workflow==null}">
			<input class="btn btn-primary" type="button" onclick="setDeliveryPerson(1,'${order.id}','${order.deliveryIndent.id }')" value="指定送货员"/>
		</c:if>
	</c:if>
	<c:if test="${workflow!=null && order.orderType<2}">
		<c:if test="${order.orderType==0 && workflow.status == 0}">
		<input value="开启流程" type="button" class="btn btn-primary" onclick="startWorkFlow('${workflow.id}','${order.deliveryIndent.id }','0')"/>
		</c:if>
		<c:if test="${workflow.status == 1 && order.orderType == 0}">
		<input value="开始派送" type="button" class="btn btn-primary" onclick="startWorkFlow('${workflow.id}','${order.deliveryIndent.id }','1')"/>
		</c:if>
		<!-- 
		<c:if test="${workflow.status == 1 && order.orderType == 1}">
		<input value="完成派送" type="button" class="btn btn-primary" onclick="startWorkFlow('${workflow.id}','${order.deliveryIndent.id }','2')"/>
		</c:if>
		 -->
	</c:if>
	<c:if test="${order.orderType<2}">
		<!-- <input id="btnSubmit" class="btn btn-primary" type="button" value="保存" onclick="saveForm()"/> -->
		<c:if test="${workflow!=null && workflow.status == 1 && order.orderType == 1}">
			<input value="完成订单" type="button" class="btn btn-primary" onclick="startWorkFlow('${workflow.id}','${order.deliveryIndent.id }','2')"/>
		</c:if>
	</c:if>	
	<!--<c:if test="${order.orderType==2}">
		<input id="btnSubmit" class="btn btn-primary" type="button" value="保存" onclick="saveForm()"/>
	</c:if>
	<c:if test="${order.orderType<2}">
		<input type="button" class="btn btn-primary" onclick="resetDelivery(0)" value="一键还原"/>
	</c:if>
	-->
	<input type="button" class="btn btn-primary" onclick="previewDelivery('${order.id}')" value="预览" style="margin-left: 5px;"/>
	<input value="导出" type="button" class="btn btn-primary" style="margin-right: 20px;margin-left:5px" onclick="exportWord('${order.id}')"/>
</div>
</c:if>
</body>
</html>